package ee.maoinvest.frontend.controller.requestprocessors;

import java.sql.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import ee.maoinvest.frontend.controller.formstringdataconverters.transformercoefficentforms.InsertTransformerCoefficentFormConverter;

public class TransformerCoefficentFormsRequestProcessor 
{
	public InsertTransformerCoefficentFormConverter fillInsertTransformerCoefficentFormConverterWithRequestData(
			HttpServletRequest request)
	{
		InsertTransformerCoefficentFormConverter insertTransformerCoefficentFormConverter = 
				new InsertTransformerCoefficentFormConverter();
		//getting data from form, that has been put on request
		String coefficent = request.getParameter("insertTransformerCoefficentCoefficent");
		String dateInserted = request.getParameter("insertTransformerCoefficentDateInserted");
		
		HttpSession session = request.getSession();
		Date latestDateAfterWhatDataManipulationIsPossible = (Date) session.getAttribute("latestDateAfterWhatDataManipulationIsPossible");
		
		insertTransformerCoefficentFormConverter.setCoefficent(coefficent);
		insertTransformerCoefficentFormConverter.setDateInserted(dateInserted);
		insertTransformerCoefficentFormConverter.setLatestDateAfterWhatDataManipulationIsPossible(
				latestDateAfterWhatDataManipulationIsPossible);
				
		return insertTransformerCoefficentFormConverter;
	}
}
